﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyLib1;
using WebApi.MyServices;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        private readonly MyService1 _myService1;
        private readonly IMyService _myService;
        private readonly ITestService _testService;

        public TestController(MyService1 myService1,IMyService myService,ITestService testService)
        {
            _myService1 = myService1;
            _myService = myService;
            _testService = testService;
        }

        [HttpGet("test")]
        public string Test()
        {
            var names = _myService1.GetNames();
            return string.Join(", ", names);
        }

        [HttpGet("TestMyService")]
        public IActionResult TestMyService()
        {
            _myService.SayHello();
            return Ok("Hello from MyService");
        }

        [HttpGet("TestMyService2")]
        public IActionResult TestMyService2()
        {
            var result = _myService.SayHi();
            return Ok(result);
        }
        [HttpGet("TestMyService3")]
        public IActionResult TestService()
        {
            _testService.TestMethod1();
            var result = _testService.TestMethod2();
            return Ok(result);
        }

        /* [HttpGet]
         public string Test([FromServices] MyService1 myService1)
         {
             var names = myService1.GetNames();
             return string.Join(", ", names);
         }*/
    }
}
